<?php
//获取帖子列表

/**
 * @var $config
 * @var $key
 * @var $FORUM_PAGE_NUMBER
 */
include 'api.php';
include '../WeSql/WeSql.php';
include '../WeSql/config.php';
include '../WeSql/widget.php';


@$page = $_REQUEST['page'];

$weSql = new WeSql($config);

if($page == "" or $page == null){
    //不分页
    $code = 1;
    $arr = $weSql->selectAll("forum","state=1");
    $msg = $arr;
    $exception = '';
}else{
    //分页
    if($weSql->getCount("forum","state=1") > $page * $FORUM_PAGE_NUMBER){
        $code = 1;
        $arr = $weSql->selectAll("forum","state=1",$page * $FORUM_PAGE_NUMBER);
        $msg = $arr;
        $exception = '';
    }else{
        $code = 1;
        $arr = $weSql->selectAll("forum","state=1");
        $msg = $arr;
        $exception = '';
    }
}

/** @var $code
 * @var $msg
 * @var $exception
 */
@$result = [
    'code' => $code,
    'msg' => $msg,
    'exception' => $exception
];
echo json_encode($result,JSON_UNESCAPED_UNICODE);